-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: atomic object update #570
feat: atomic object update #570
Conversation
56e56a4
to
c6860c2
Compare
f956aac
to
bc85d0f
Compare
bc85d0f
to
de62f2c
Compare
x/storage/keeper/keeper.go
Outdated
return err | ||
} | ||
} | ||
_ = k.MustGetPrimarySPForBucket(ctx, bucketInfo) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line _ = k.MustGetPrimarySPForBucket(ctx, bucketInfo)
is not needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
x/storage/types/keys.go
Outdated
@@ -101,6 +112,12 @@ func GetObjectByIDKey(objectId math.Uint) []byte { | |||
return append(ObjectByIDPrefix, seq.EncodeSequence(objectId)...) | |||
} | |||
|
|||
// GetShadowObjectByIDKey return the shadowObjectId store key | |||
func GetShadowObjectByIDKey(objectId math.Uint) []byte { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need bucketName + objectName
-> id
-> shadow object
.
We can just bucketName + objectName
-> shadow object
, to save storage and make code easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, change is applied.
return err | ||
} | ||
} else { | ||
objectInfo.IsUpdating = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IsUpdating
is a temp field. It seems better we just put into ShadowObjectInfo
- so it will be deleted with shadow object to save storage.
x/storage/keeper/keeper.go
Outdated
} | ||
|
||
bbz := k.cdc.MustMarshal(bucketInfo) | ||
store.Set(types.GetBucketByIDKey(bucketInfo.Id), bbz) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we change bucketInfo
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no change made, removed.
return errors.Wrapf(types.ErrAccessDenied, "Only allowed owner/updater to do cancel update object") | ||
} | ||
|
||
objectInfo.IsUpdating = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put IsUpdating
into shadowObject
will reduce such codes.
7c2a794
to
8fe3000
Compare
Description
Enable atomic object update.
More details please refer to bnb-chain/BEPs#346
Rationale
tell us why we need these changes...
Example
add an example CLI or API response...
Changes
Notable changes:
Potential Impacts